import http from "@/api";

export namespace Holiday {
  // 假期数据接口
  export interface HolidayData {
    date: string;
    type: 'work' | 'holiday';
    remark?: string;
  }

  // 获取假期数据请求参数
  export interface GetHolidayDataParams {
    yearMonth: string; // 格式: YYYY-MM
  }

  // 保存假期数据请求参数
  export interface SaveHolidayDataParams {
    date: string;
    type: 'work' | 'holiday';
    remark?: string;
  }

  // 批量保存假期数据请求参数
  export interface BatchSaveHolidayDataParams {
    data: SaveHolidayDataParams[];
  }
}

/**
 * @name 假期管理模块
 */
// 获取指定月份的假期数据
export const getHolidayData = (params: Holiday.GetHolidayDataParams) => {
  return http.get<Record<string, Holiday.HolidayData>>(`/holiday/data`, params, { cancel: false });
};

// 保存单个假期数据
export const saveHolidayData = (params: Holiday.SaveHolidayDataParams) => {
  return http.post(`/holiday/save`, params);
};

// 批量保存假期数据
export const batchSaveHolidayData = (params: Holiday.BatchSaveHolidayDataParams) => {
  return http.post(`/holiday/batch-save`, params);
};

// 删除假期数据
export const deleteHolidayData = (date: string) => {
  return http.delete(`/holiday/delete/${date}`);
};

// 获取假期统计数据
export const getHolidayStatistics = (params: { year: number }) => {
  return http.get(`/holiday/statistics`, params);
};